<template>
  <div class="sidebar_trend_content">
    <div class="trend-title">
      <p>最近一周的告警趋势</p>
    </div>
    <div class="trend-charts" ref="trend_charts">

    </div>
  </div>
</template>
<script>
import * as ec from "echarts"

export default {
  name: "sidebar_trend",
  data() {
    return {
      echartsinstance: null,
      options: {
        tooltip: {
          trigger: 'item',
          formatter: '{b} {c}次',
        },
        xAxis: {
          type: 'category',
          data: ['3号', '4号', '5号', '6号', '7号', '8号', '9号']
        },
        yAxis: {
          type: 'value'
        },
        series: [
          {
            data: [23, 87, 45, 66, 9, 0, 56],
            type: 'line',
            smooth: true
          }
        ]
      },
    }
  },
  mounted() {
    this.echartsinstance = ec.init(this.$refs.trend_charts)
    this.echartsinstance.setOption(this.options)
    this.$emit('resize_trend', this.echartsinstance)
  },
  watch: {
    options() {
      this.echartsinstance.setOption(this.options)
    }
  }
}
</script>
<style lang="scss" scoped>
$trendW: vw(478.67);
$trendH: vh(513.2);
$trendCh: vh(513.2-35);

.trend-charts {
  width: 100%;
  height: $trendCh;
}

.trend-title {
  width: 100%;
  height: vh(35);
  padding-left: vw(37);
  color: #04DEFF;
  font-size: vh(22);
  position: relative;

  p {
    position: absolute;
    bottom: 0;
  }
}

.sidebar_trend_content {
  width: $trendW;
  height: $trendH;
  margin-left: vw(21);
  margin-top: vh(17);
  background: linear-gradient(180deg, rgba(0, 47, 111, 0.7) 0%, rgba(0, 34, 80, 0.5) 100%);
  opacity: 1;
  border: 1px solid rgba(117, 210, 227, 0.07);

  background-image: url('../assets/image/sidebar_trend.png');
  background-repeat: no-repeat;
  background-position: center;

  -webkit-background-size: cover;
  -moz-background-size: cover;
  -o-background-size: cover;
}
</style>
